import VueRouter from "vue-router";
import Vue  from "vue";

Vue.use(VueRouter)

const routes = [
  { path: '/',redirect:'/index' },
  { 
    path: '/index',
    component:()=>import('../view/index'),
    redirect:'/index/banners',
    meta:{title:"首页"},
    children:[
      {
        path: 'banners',
        meta:{title:"轮播图管理"}, 
        component:()=>import('../view/shouye/banner'),
        beforeEnter:(to,from,next) =>{
          next()
        }
      },
      {path: 'category',meta:{title:"分类管理"}, component:()=>import('../view/shouye/category')},
      {path: 'recommend',meta:{title:"为你推荐管理"}, component:()=>import('../view/shouye/recommend')},
      {
        path:'article',meta:{title:"新闻管理"},component:()=>import('../view/article/article.vue')
      },
      {
        path:'brands',meta:{title:"品牌管理"},component:()=>import('../view/goods/brand.vue')
      },
      {
        path:'product',meta:{title:"商品管理"},component:()=>import('../view/goods/product')
      },
      {
        path:'sku',meta:{title:"单品管理"},component:()=>import('../view/goods/sku')
      },
      {
        path:'productCategory',meta:{title:"分类管理"},component:()=>import('../view/goods/productCategory')
      },
      {
        path:'productSku/:id',meta:{title:"分类商品管理"},component:()=>import('../view/goods/productSku')
      }
    ]
  },
  { path: '/login', component:()=>import('../view/login' )},

]
const router =new VueRouter({
  routes, // `routes: routes` 的缩写
})

export default router